#include "DriverManager.h"

#include "MceIrDrv.h"
#include "ODSLogger.h"
#include "SonyDecoder.h"
#include "NECDecoder.h"
#include "RC5Decoder.h"
#include "RC6Decoder.h"
#include "REC80Decoder.h"

DriverManager::DriverManager () : m_Logger ( new ODSLogger() ), m_Decoders ( new IrDecoderManager(m_Logger) ), m_Publisher ( new Publisher() )
{
	m_Decoders->add ( new SonyDecoder( m_Logger, m_Publisher ) ) ;
	m_Decoders->add ( new NecDecoder( m_Logger, m_Publisher ) ) ;
	m_Decoders->add ( new RC5Decoder( m_Logger, m_Publisher ) ) ;
	m_Decoders->add ( new RC6Decoder( m_Logger, m_Publisher ) ) ;
	m_Decoders->add ( new REC80Decoder( m_Logger, m_Publisher ) ) ;

	IrDeviceList dl(m_Logger);
	IrDeviceList::StringList::iterator begin = dl.get().begin();
	
	while ( begin != dl.get().end() )
	{
		std::string path = (*begin).c_str();
		m_Logger->log(ILogger::L_INFO, path.c_str());
		IMceIrDrvPtr p ( new MceIrDrv( m_Logger, m_Decoders, path.c_str() ) );
		p->init();
		m_Drivers.push_back(p);
		begin++;		
	}

}


DriverManager::~DriverManager ()
{

}


DriverManager::DriverList & DriverManager::get()
{
	return m_Drivers;
}

PublisherPtr DriverManager::publisher()
{
	return m_Publisher;
}